/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.game.wordpuzzle;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author AritomoAbe
 */
public class StartGameAction implements GameAction {

    @Override
    public void processActionRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String user = request.getParameter("userId");
        GameManager gameManager = GameManager.getGameManager();
        String gameId = gameManager.startGame();
        gameManager.getActiveGame(gameId).setOwnerName(user);
        
        PrintWriter out = response.getWriter();
        try {
            out.println(gameId);
        } finally {
            out.close();
        }
    }
}
